package controllers

import (
	"github.com/astaxie/beego"
        //"mgweb/models"
        //"strings"
        //"fmt"
)

type LoginController struct {
	beego.Controller
}

func (this *LoginController) Get() {
	this.TplName = "login.tpl"
}

func (this *LoginController) Post() {
        webpasswd := this.GetString("uri")
        passwd := beego.AppConfig.String("password")
        beego.Debug(passwd)
        beego.Debug(webpasswd)
        if passwd == webpasswd {
            this.SetSession("user", "user")
        }
        this.Redirect("/", 302)
}

type LogoutController struct {
        beego.Controller
}

func (this *LogoutController) Get() {
        this.DelSession("passwd")
        this.DestroySession()
        this.Redirect("/login", 302)
}
